home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / nfsrc21.zip / SHADOW.ASM < prev    next >
Assembly Source File  |  1992-10-16  |  6KB  |  155 lines

  1. ; File......: SHADOW.ASM
  2. ; Author....: Ted Means
  3. ; Date......: $Date:   16 Oct 1992 00:07:06  $
  4. ; Revision..: $Revision:   1.4  $
  5. ; Log file..: $Logfile:   C:/nanfor/src/shadow.asv  $
  6. ; This is an original work by Ted Means and is placed in the
  7. ; public domain.
  8. ;
  9. ; Modification history:
  10. ; ---------------------
  11. ;
  12. ; $Log:   C:/nanfor/src/shadow.asv  $
  13. ;  
  14. ;     Rev 1.4   16 Oct 1992 00:07:06   GLENN
  15. ;  Just making sure we had Ted's current revision.
  16. ;  
  17. ;     Rev 1.3   28 Sep 1992 21:41:06   GLENN
  18. ;  Ted Means completely and totally rewrote this to compile under TASM's
  19. ;  IDEAL mode, with more features.  See the documentation.  It should be
  20. ;  compatible with the old Reginald Walton function, but is much faster.
  21. ;  
  22. ;     Rev 1.2   15 Aug 1991 23:07:26   GLENN
  23. ;  Forest Belt proofread/edited/cleaned up doc
  24. ;  
  25. ;     Rev 1.1   11 May 1991 00:29:22   GLENN
  26. ;  Major re-write by Ted Means.  He sped it up.  It will also cooperate
  27. ;  with Clipper's internal _gtmaxrow and _gtmaxcol settings.  
  28. ;  
  29. ;     Rev 1.0   02 Apr 1991 18:25:40   GLENN
  30. ;  Nanforum Toolkit
  31. ;
  32. ;
  33.  
  34. ;  $DOC$
  35. ;  $FUNCNAME$
  36. ;      FT_SHADOW()
  37. ;  $CATEGORY$
  38. ;      Video
  39. ;  $ONELINER$
  40. ;      Draw a non-destructive shadow on the screen
  41. ;  $SYNTAX$
  42. ;     FT_SHADOW( <nTop>, <nLeft>, <nBottom>, <nRight>, <nAttr> ) -> NIL
  43. ;  $ARGUMENTS$
  44. ;     <nTop>    is the top row of the shadow area.
  45. ;     <nLeft>   is the upper left column of the shadow area.
  46. ;     <nBottom> is the bottom row of the shadow area.
  47. ;     <nRight>  is the lower right column of the shadow area.
  48. ;     <nAttr>   is the screen attribute to use for drawing the shadow.
  49. ;  $RETURNS$
  50. ;     NIL
  51. ;  $DESCRIPTION$
  52. ;     This function allows you to implement the popular "shadow effect."  It
  53. ;     draws a shadow using the specified screen coordinates.  The entire
  54. ;     specified region is shadowed.
  55. ;
  56. ;     *** INTERNALS ALERT ***  This function uses several Clipper internal 
  57. ;     routines.  If using internals scares you, then stay away from this
  58. ;     function, you gutless weasel.  The use of the internals helps to make
  59. ;     the function more well-behaved.  Clipper's display context is not
  60. ;     violated -- if you use dispbegin() before drawing the shadow, it will
  61. ;     not appear until the corresponding call to dispend().  This makes for
  62. ;     much smoother screen i/o if you have several screen objects that
  63. ;     you wish to shadow.
  64. ;
  65. ;     The source code is written to TASM IDEAL mode.
  66. ;  $EXAMPLES$
  67. ;     FT_Shadow(10,10,10,50, 8)  // draw a dim shadow
  68. ;        
  69. ;     FT_Shadow(10,10,10,40,47)  // draw a green shadow
  70. ;  $END$
  71.  
  72. IDEAL                                        ; Invoke TASM IDEAL mode
  73.  
  74. Public   FT_Shadow
  75.  
  76. Extrn    __ParNI:Far
  77. Extrn    __xGrab:Far
  78. Extrn    __xFree:Far
  79. Extrn    __gtSave:Far                        ; INTERNAL!!!
  80. Extrn    __gtRest:Far                        ; INTERNAL!!!
  81.  
  82. nTop     EQU       Word Ptr BP - 2
  83. nLeft    EQU       Word Ptr BP - 4
  84. nBottom  EQU       Word Ptr BP - 6
  85. nRight   EQU       Word Ptr BP - 8
  86. nAttr    EQU       Byte Ptr BP - 10
  87. nSize    EQU       Word Ptr BP - 12
  88.  
  89. Segment  _NanFor   Word      Public    "CODE"
  90.          Assume    CS:_NanFor
  91.  
  92. Proc     FT_Shadow Far
  93.  
  94.          Push      BP                        ; Save BP
  95.          Mov       BP,SP                     ; Set up stack reference
  96.          Sub       SP,12                     ; Allocate locals
  97.  
  98.          Mov       CX,5                      ; Set param count
  99. @@Coord: Push      CX                        ; Put on stack
  100.          Call      __ParNI                   ; Retrieve param
  101.          Pop       CX                        ; Get count back
  102.          Push      AX                        ; Put value on stack
  103.          Loop      @@Coord                   ; Get next value
  104.  
  105.          Pop       [nTop]                    ; Get top coordinate
  106.          Pop       [nLeft]                   ; Get left coordinate
  107.          Pop       [nBottom]                 ; Get bottom coordinate
  108.          Pop       [nRight]                  ; Get right coordinate
  109.          Pop       [Word Ptr BP - 10]        ; Get attribute
  110.  
  111.          Mov       AX,[nBottom]              ; Load bottom coordinate
  112.          Sub       AX,[nTop]                 ; Subtract top
  113.          Inc       AX                        ; Calc length
  114.  
  115.          Mov       DX,[nRight]               ; Load right coordinate
  116.          Sub       DX,[nLeft]                ; Subtract left
  117.          Inc       DX                        ; Calc width
  118.          Mul       DX                        ; Calc buffer size
  119.          Mov       [nSize],AX                ; Store size
  120.  
  121.          SHL       AX,1                      ; Account for attribute bytes
  122.          Push      AX                        ; Put size on stack
  123.          Call      __xGrab                   ; Allocate virtual memory
  124.  
  125.          Push      DX                        ; Put buffer segment on stack
  126.          Push      AX                        ; Put buffer offset on stack
  127.          Push      [nRight]
  128.          Push      [nBottom]                 ; Get bottom coordinate
  129.          Push      [nLeft]
  130.          Push      [nTop]                    ; Get top row
  131.          Call      __gtSave                  ; Save screen image
  132.  
  133.          Mov       BX,SP                     ; Point BX to buffer pointer
  134.          Mov       AL,[nAttr]                ; Get attribute
  135.          Mov       CX,[nSize]                ; Get length
  136.          Push      DI                        ; Save DI
  137.          LES       DI,[SS:BX + 8]            ; Load pointer to buffer
  138. @@Top:   Inc       DI                        ; Point to attribute byte
  139.          Stosb                               ; Set attribute
  140.          Loop      @@Top                     ; Do next byte
  141.          Pop       DI                        ; Restore DI
  142.          Call      __gtRest                  ; Put shadowed image onscreen
  143.  
  144. @@Done:  Add       SP,8                      ; Remove params from stack
  145.          Call      __xFree                   ; Free buffer
  146.          Mov       SP,BP                     ; Realign stack
  147.          Pop       BP                        ; Restore BP
  148.          Ret
  149. Endp     FT_Shadow
  150. Ends     _NanFor
  151. End
  152.  
  153.  
  154.